package com.powernode.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.support.RequestPartServletServerHttpRequest;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 刘冠志
 * 2023/1/6
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * swagger会帮助我们生成接口文档
     * 1.配置文档信息
     * 2.配置接口信息
     */


    /**
     * Docket封装接口信息
     * @return
     */
    @Bean
    public Docket getDocket(){
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("商场后端接口文档")
                .description("这是描述信息")
                .version("v2.0.1")
                .contact(new Contact("作者相关","www.baidu.com","1439618697@qq.com"))
                .build();
        //apiInfo指定生产的文档中的封面信息,文档标题,版本,作者
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.powernode.controller"))
                .paths(PathSelectors.any()) //regex("/user/")给指定的接口作文档,any给全部都接口作文档
                .build();
        return docket;
    }




}
